﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AMS.WebDL.Php.Controllers;

namespace AMS.WebDL.Php.Views
{
    public partial class RangedPhpDownloaderForm : Form
    {
        private RangedPhpDownloaderController _controller;

        public string WebFolderAddress
        {
            get { return txtWebFolder.Text; }
            set { txtWebFolder.Text = value; }
        }

        public string WebPageName
        {
            get { return txtWebPage.Text; }
            set { txtWebPage.Text = value; }
        }

        public string ElementName
        {
            get { return txtElement.Text; }
            set { txtElement.Text = value; }
        }

        public int First
        {
            get { return Convert.ToInt32(txtFirst.Text); }
            set { txtFirst.Text = value.ToString(); }
        }

        public int Last
        {
            get { return Convert.ToInt32(txtLast.Text); }
            set { txtLast.Text = value.ToString(); }
        }

        public bool EnableDownload
        {
            get { return btnDownload.Enabled; }
            set { btnDownload.Enabled = value; }
        }

        public RangedPhpDownloaderForm(RangedPhpDownloaderController controller)
        {
            InitializeComponent();

            this._controller = controller;

            // subscribe to events
        }

        private void HandleNumberTextBoxKeyPress(object sender, KeyPressEventArgs e)
        {
            TextBox box = sender as TextBox;
            if (char.IsDigit(e.KeyChar))
            //   || (e.KeyChar == '.' && !box.Text.Contains('.')))
                return;

            e.Handled = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderDialog = new FolderBrowserDialog();

            if (folderDialog.ShowDialog() == DialogResult.OK)
            {
                EnableDownload = true;
                txtLocalFolder.Text = folderDialog.SelectedPath;
            }
        }
    }
}
